<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://unpkg.com/vue@next"></script>
  <style>
    .active {
      color: red;
    }
  </style>
</head>
<body>
  <div id="app">
    <button @click="change">改变父组件中的值：{{ hello }}</button><br/>
    <blog-post-row :title="hello" @update:title="title = $event"></blog-post-row>
  </div>

  <script>
    const app = Vue.createApp({
      setup() {
        const hello = Vue.ref('hello')
        const change = () => {
          hello.value = 'world'
        }
        return { hello, change }
      }
    })

    app.component('blog-post-row', {
      props: {
        title: String
      },
      setup(props, context) {
        let changeFather = () => {
          console.log('11')
          context.emit('update:title', '被子组件改变了')
        }
        return { changeFather }
      },
      template: `
      <button @click="changeFather">子组件想改变父组件中的值：{{ title }}</button>
      <div>我是div组件{{ title }}</div>
      `
    })

    app.mount('#app')
  </script>
</body>
</html>